package com.heima.config;

import com.heima.properties.AliyunProperties;
import com.heima.utils.AliyunOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ljk74
 */
@Configuration
@Slf4j
public class OSSConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public AliyunOssUtil aliyunOssUtil(AliyunProperties aliyunProperties){
        return new AliyunOssUtil(aliyunProperties.getEndpoint(),
                aliyunProperties.getAccessKeyId(),
                aliyunProperties.getAccessKeySecret(),
                aliyunProperties.getBucketName());
    }
}
